package Transforming_Observables

import (
	"encoding/json"
	"fmt"
	"github.com/reactivex/rxgo/v2"
)

type customer struct {
	ID int `json:"id"`
}

// 吧每一个对象序列化成其他协议对象
func Demo_Marshal() {
	fmt.Println("Demo_BufferWithCount###########################")
	observable := rxgo.Just(
		customer{
			ID: 1,
		},
		customer{
			ID: 2,
		},
	)().Marshal(json.Marshal)

	for item := range observable.Observe() {
		if item.Error() {
			fmt.Println("订阅：", item.E)
		}
		fmt.Println("订阅：", item.V)
	}
}
